/*
@Author   : Uyynot
@Email    : uyynot@qq.com
@Time     : 2023/8/24 14:09
@File     : common.go
@Project  : web_scaff
@Desc     :
*/
package common

import (
	"fmt"

	"github.com/gin-gonic/gin"
)

type PageInfo struct {
	Page     int `json:"page" form:"page"`
	PageSize int `json:"page_size" form:"page_size"`
}

func GetPageInfo(c *gin.Context) (pageInfo PageInfo) {
	if err := c.ShouldBindQuery(&pageInfo); err != nil {
		fmt.Println("ERR:", err.Error())
	}
	fmt.Println("pageInfo:", pageInfo)

	if pageInfo.Page <= 0 {
		pageInfo.Page = 1
	}
	if pageInfo.PageSize <= 0 {
		pageInfo.PageSize = 10
	}
	return
}
